package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.mapper.WmUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class WmUserController {
    @Autowired
    private WmUserMapper wmUserMapper;
    @PostMapping("/api/v1/user/save")
    public ResponseResult add(@RequestBody WmUser wmUser){
        wmUserMapper.insert(wmUser);
        return ResponseResult.okResult(wmUser.getId());
    }

    @PostMapping("/api/v1/user/update")
    void update(@RequestParam Integer authorId, @RequestParam Integer wmUserId){
        WmUser wmUser = new WmUser();
        wmUser.setId(wmUserId);
        wmUser.setApAuthorId(authorId);
        wmUserMapper.updateById(wmUser);
    }
}
